/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.srcptit.javatrainning.hieptq.b2;

import java.util.Scanner;

/**
 *
 * @author Hiep
 */
public class String4 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        boolean ok=true;
        System.out.print("Nhap so: ");
        while(ok){
            try{
                ok = false;
                int a = Integer.parseInt(sc.nextLine());
                System.out.println(a);// neu dung se in ra,neu sai se nhay xuong cau lenh catch
            }catch(NumberFormatException e){ //neu sai nhap lai
                System.out.print("Nhap lai: ");
                ok = true;
            }finally{
                System.out.println("Always!");// dung hay sai deu in ra Always!
            }
        }
    }
}
